<template>
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="设备名称">
      <el-input v-model="form.deviceName"></el-input>
    </el-form-item>
    <el-form-item label="所属车间">
      <el-select v-model="form.deviceWorkshop" placeholder="请选择活动区域">
      </el-select>
    </el-form-item>
    <el-form-item label="故障位置">
      <el-input v-model="form.faultPosition"></el-input>
    </el-form-item>
    <el-form-item label="负责人">
      <el-input v-model="form.deviceManager" ref="a1"></el-input>
    </el-form-item>
    <el-button type="primary" @click="onSubmit">立即提交</el-button>
  </el-form>
</template>

<script>
import { faultForm } from "@/api/system/manage";
export default {
  name: "gzxq",
  data() {
    return {
      form: {
        deviceName: "",
        deviceWorkshop: "",
        faultPosition: "",
        deviceManager: "",
      },
    };
  },
  mounted() {
    this.formDataa();
  },
  methods: {
    formDataa() {
      this.form.deviceName = this.$route.query.data.name;
      this.form.deviceWorkshop = this.$route.query.data.deviceWorkshop;
    },
    onSubmit() {
      if (this.form.faultPosition === "" && this.form.deviceManager === "") {
        alert("请填写鼓掌位置和负责人");
      } else if (this.form.deviceManager === "") {
        alert("请填写负责人");
      } else if (this.form.faultPosition === "") {
        alert("请填写鼓掌位置");
      } else {
        faultForm(this.form).then((res) => {
          alert("提交成功！");
        });
      }
    },
  },
};
</script>

<style>
.el-button {
  margin-left: 160px;
}
</style>
